<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>index</title>
    <link href="../css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="../css/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../css/cw.css"/>
    <style type="text/css">
    	.mui-bar-tab .mui-tab-item.mui-active {color:#8dc21f;}
    </style>
</head> 
<body>
	<nav class="mui-bar mui-bar-tab "style="background:transparent;">
        <a class="mui-tab-item personal mui-active" href="home.html">
            <i class="mui-icon iconfont">&#xe610;</i>
            <span class="mui-tab-label me-bar-top">绥夏医生</span>
        </a>
        <a class="mui-tab-item personal " href="jk-home.html">
            <i class="mui-icon iconfont" >&#xe60f;</i>
            <span class="mui-tab-label me-bar-top">健康</span>
        </a>
        <a class="mui-tab-item personal " href="bbs-text-list.html">
            <i class="mui-icon iconfont" >&#xe612;</i>
            <span class="mui-tab-label me-bar-top">互动圈</span>
        </a>
        <a class="mui-tab-item personal " href="me-centre.html">
            <i class="mui-icon iconfont" >&#xe611;</i>
            <span class="mui-tab-label me-bar-top">个人中心</span>
        </a>
	</nav>
</body>
<script src="../js/mui.min.js"></script>
<script src="../js/jquery-2.1.4.min.js"></script>
<script src="../js/global.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="UTF-8">
    //mui初始化
	mui.init();
	var subpages = ['home.html','jk-home.html','bbs-text-list.html','me-centre.html']; 
	var subpage_style = {
		bottom: '51px',
		scrollIndicator: 'none'
	};
	//解决苹果头部拖动问题
	if(mui.os.android){
		subpage_style.bounce = 'vertical';
	}
	
	var aniShow = {};
	 //创建子页面，首个选项卡页面显示，其它均隐藏；
	mui.plusReady(function() {
		var self = plus.webview.currentWebview();
		for (var i = 0; i < subpages.length; i++) {
			var temp = {};
			if(i>=0){
			subpage_style.top = "0";
			}
			var sub = plus.webview.create(subpages[i], subpages[i], subpage_style);
			if (i > 0) {
				sub.hide();
			} else {
				temp[subpages[i]] = "true";
				mui.extend(aniShow, temp);
			}
			self.append(sub);
		}
	});
	//当前激活选项
	var activeTab = subpages[0];
	var title = document.getElementById("title");
	 //选项卡点击事件
	mui('.mui-bar-tab').on('tap', 'a', function(e) {
		var targetTab = this.getAttribute('href');
		if (targetTab == activeTab) {
			return;
		}
		//更换标题
		//显示目标选项卡
		if (mui.os.ios || aniShow[targetTab]) {
			plus.webview.show(targetTab);
		} else {
			var temp = {};
			temp[targetTab] = "true";
			mui.extend(aniShow, temp);
			plus.webview.show(targetTab, "fade-in", 300);
		}
		//隐藏当前;
		plus.webview.hide(activeTab);
		
		//更改当前活跃的选项卡
		activeTab = targetTab;
	});
	 //自定义事件，模拟点击“首页选项卡”
	document.addEventListener('gohome', function() { 
		var defaultTab = document.getElementById("defaultTab");
		//模拟首页点击
		mui.trigger(defaultTab, 'tap');
		//切换选项卡高亮
		var current = document.querySelector(".mui-bar-tab>.mui-tab-item.mui-active");
		if (defaultTab !== current) {
			current.classList.remove('mui-active');
			defaultTab.classList.add('mui-active');
		}
	});
	var first = null;
	mui.back = function() {
		//首次按键，提示‘再按一次退出应用’
		if (!first) {
			first = new Date().getTime();
			mui.toast('再按一次退出应用');
			setTimeout(function() {
				first = null;
			}, 2000);
		} else {
			if (new Date().getTime() - first < 2000) {
				plus.runtime.quit();
			}
		}
	};
	
	</script>
</html>